<div class="card">
    <h2>修改密码</h2>
    <div style="width:400px">
        <form action="/admin/editPswd" id="edit-pswd-form" method="post">
            <div class="form-item">
                <div class="label">旧密码</div>
                <div class="input">
                    <input type="password" name="old_password">
                </div>
            </div>
            <div class="form-item">
                <div class="label">新密码</div>
                <div class="input">
                    <input type="password" name="new_password">
                </div>
            </div>
            <div class="form-item">
                <div class="label">确认密码</div>
                <div class="input">
                    <input type="password" name="confirm_password">
                </div>
            </div>
            <div class="form-item" style="text-align: right;">
                <button type="submit">修改</button>
            </div>
        </form>
    </div>
</div>
<script id="edit-pswd-form-script">
    regInitFun('edit-pswd-form-script',()=>{
        document.getElementById('edit-pswd-form').onsubmit = ev=>{
            ev.preventDefault();
            var form = ev.target;
            var oldPassword = form.elements.old_password.value;
            var newPassword = form.elements.new_password.value;
            var confirmPassword = form.elements.confirm_password.value;
            if(oldPassword==""){
                alert('请输入旧密码')
                return;
            }
            if(newPassword==""){
                alert('请输入新密码')
                return;
            }
            if(confirmPassword==""){
                alert('请再次输入新密码')
                return;
            }
            if(newPassword != confirmPassword){
                alert('两次输入的密码不一致');
                return;
            }
            form.submit();
        }
    })
</script>